// export const debounce = (fun, time) => {
// 	let timer = null;
// 	// console.log(this, target)
// 	// console.log(fun, time)
// 	return function (...args) {
// 		if(timer) clearTimeout(timer)
// 		timer = setTimeout(() => {
// 			fun.apply(this, args)
// 		}, time)
// 	}
// }
// export const throttle = (fun, time) => {
// 	let timer = null
// 	time = time || 1000
// 	return function(...args) {
// 		if(timer) return
// 		timer = setTimeout(() => {
// 			timer = null
// 		}, time)
// 		fun.apply(this, args)
// 	}
// }

export const debounce = (fun, time) => {
	let timer = null
	return function(...args) {
		if(timer) clearTimeout(timer)
		timer = setTimeout(function() {
			fun.apply(this, args)
		}, time)
	}
}

export const throttle = (fun, time) => {
	let timer = null
	return function(...args) {
		if(timer) {
			return
		}
		timer = setTimeout(() => {
			clearTimeout(timer)
			timer = null
		}, time)
		fun.apply(this, args)
	}
}

